package com.springcloud.controller;

import ch.qos.logback.classic.Logger;
import com.springcloud.commons.utils.StringUtils;
import com.springcloud.service.OrderService;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;


/**
 *
 * ClsTradeOrder 控制层
 *
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    /**
     * 查询订单
     * @param name
     * @return
     */
    @RequestMapping("/find")
    public Object find(String name) {
//        return "order-conntroller";
        if(StringUtils.isBlank(name)){
            name = "car";
        }
        return orderService.find(name);

    }

    /*@KafkaListener(topics = {"log"})
    public void listen(ConsumerRecord<?, ?> record) {

        Optional<?> kafkaMessage = Optional.ofNullable(record.value());

        if (kafkaMessage.isPresent()) {

            Object message = kafkaMessage.get();
            System.out.println(message);
        }

    }*/

}